package cn.chengpengper.seckill.reservation.domain.model.entity;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * @author chengpeng.hu
 */
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SeckillReservationUser implements Serializable {
    private static final long serialVersionUID = -4237615389803008108L;

    /**
     * 预约记录id
     */
    private Long id;
    /**
     * 预约配置id
     */
    private Long reserveConfigId;
    /**
     * 商品id
     */
    private Long goodsId;
    /**
     * 商品名称
     */
    private String goodsName;
    /**
     * 用户id
     */
    private Long userId;
    /**
     * 预约时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date reserveTime;
    /**
     * 状态,1:正常;0:删除
     */
    private Integer status;

    public boolean isEmpty() {
        return id == null
                || reserveConfigId == null
                || goodsId == null
                || StrUtil.isEmpty(goodsName)
                || userId == null
                || reserveTime == null;
    }

}
